home *** CD-ROM | disk | FTP | other *** search
/ Libris Britannia 4 / science library(b).zip / science library(b) / DDJMAG / DDJ9203.ZIP / OOPASM.ZIP / HELP.ASM < prev    next >
Assembly Source File  |  1990-07-18  |  4KB  |  176 lines

  1.     .MODEL    SMALL
  2.  
  3.     INCLUDE    equates.inc
  4.     INCLUDE    instance.inc
  5.     INCLUDE    messages.inc
  6.     INCLUDE    objects.inc
  7.  
  8.     UR        EQU    1            ;Upper row
  9.     LC        EQU    70            ;Left column
  10.     LR        EQU    21            ;Lower row
  11.     RC        EQU    79            ;Right column
  12.     NumOfItems    EQU    10            ;Number of menu items
  13.     MenuColor    EQU    17h            ;Menu color
  14.     WinColor    EQU    31h            ;Window color
  15.  
  16. IF1
  17.     INCLUDE    macros.mac
  18.     INCLUDE    objects.mac
  19. ENDIF
  20.  
  21.     EXTRN    prtString:NEAR
  22.     EXTRN    sendMsg:NEAR
  23.  
  24.     EXTRN    Hardware:WORD
  25.     EXTRN    Menu:WORD
  26.     EXTRN    Mouse:WORD
  27.     EXTRN    Self:WORD
  28.     EXTRN    System:WORD
  29.     EXTRN    Window:WORD
  30.  
  31.     .CODE
  32.  
  33. IF Dbug
  34.     PUBLIC    disHelpMenu
  35. ENDIF
  36. COMMENT    %
  37. ==============================================================================
  38. Displays the help menu.
  39.  
  40. =============================================================================%
  41. disHelpMenu    PROC    NEAR
  42.     getInst        dh,Row1,Self        ;Get upper row
  43.     inc        dh            ;Increment it
  44.     getInst        dl,Col1            ;Get left column
  45.     getInst        bl,Color        ;Get color
  46.     getInst        di,MenuPtr        ;Ptr to menu text
  47.     mov        cx,NumOfItems        ;Set loop counter
  48.  
  49. dhm1:    mov        Wptr[di],dx        ;Save row/column
  50.     mov        si,Wptr[di+2]        ;Point to menu item text
  51.     call        prtString        ;Display it
  52.     add        dh,2            ;Increment row by two
  53.     add        di,4            ;Point to next menu item
  54.     loop        dhm1            ;Loop if more items
  55.     ret
  56. disHelpMenu    ENDP
  57.  
  58.  
  59.  
  60. IF Dbug
  61.     PUBLIC    resetColor
  62. ENDIF
  63. COMMENT    %
  64. ==============================================================================
  65. Resets the colors of the help menu.
  66.  
  67. =============================================================================%
  68. resetColor    PROC    NEAR
  69.     setInst        Color,MenuColor,Self,1    ;Reset color
  70.     ret
  71. resetColor    ENDP
  72.  
  73.  
  74.  
  75. IF Dbug
  76.     PUBLIC    setColor
  77. ENDIF
  78. COMMENT    %
  79. ==============================================================================
  80. Sets the colors of the help menu.
  81.  
  82. =============================================================================%
  83. setColor    PROC    NEAR
  84.     setInst        Color,WinColor,Self,1    ;Set window color
  85.     ret
  86. setColor    ENDP
  87.  
  88.  
  89.  
  90. IF Dbug
  91.     PUBLIC    clickOnButton
  92. ENDIF
  93. COMMENT    %
  94. ==============================================================================
  95. Selects the menu item based on mouse location.
  96.  
  97. =============================================================================%
  98. clickOnButton    PROC    NEAR
  99.     getInst        bl,Row1,Mouse        ;Get mouse row
  100.     getInst        si,MenuPtr,Self        ;Get menu ptr
  101.     xor        ax,ax            ;Initialize item counter
  102.                          
  103. cob1:    mov        dl,Bptr[si+1]        ;Get row for current item
  104.     mov        dh,Bptr[si+1+MenuEntrySize]        ;Get row for next item
  105.     lessThan    bl,dl,cob4        ;Exit if before item
  106.     lessThan    bl,dh,cob3        ;Done if before next item
  107.     inc        ax            ;Increment item count
  108.     add        si,MenuEntrySize    ;Point to next entry
  109.     identity    Wptr[si],cob1,cob4    ;Loop if more items
  110.                         ;Else exit
  111.  
  112. cob3:    mov        cl,MenuEntrySize    ;Get entry size
  113.     mul        cl            ;Calc entry offset
  114.     send        Self,Flash,ax        ;Flash hilite for menu item
  115.     send        Self,DeHilite,ax    ;Turn menu item off
  116.     send        Self,Select        ;Select menu item
  117.  
  118. cob4:    ret
  119. clickOnButton    ENDP
  120.  
  121.  
  122.  
  123.     .DATA
  124.  
  125. defMenu    Help,\
  126.     <" F1  Help ",\
  127.      " F2       ",\
  128.      " F3       ",\
  129.      " F4       ",\
  130.      " F5       ",\
  131.      " F6       ",\
  132.      " F7       ",\
  133.      " F8       ",\
  134.      " F9       ",\
  135.      " F10 Quit ">
  136.  
  137. defMenuTbl    Help,\
  138.     <Hardware,Refresh>,\
  139.     <Hardware,Refresh>,\
  140.     <Hardware,Refresh>,\
  141.     <Hardware,Refresh>,\
  142.     <Hardware,Refresh>,\
  143.     <Hardware,Refresh>,\
  144.     <Hardware,Refresh>,\
  145.     <Hardware,Refresh>,\
  146.     <Hardware,Refresh>,\
  147.     <System,Refresh,System,Read>
  148.  
  149. defMsg    Help,\
  150.     Refresh,\
  151.     <setColor,resetColor,disHelpMenu>
  152.  
  153. defMsg    Help,\
  154.     Click,\
  155.     <,,clickOnButton>
  156.  
  157. defObj    Help,\
  158.     <Window,Menu>,\
  159.     <Row1,1,UR,\
  160.     Col1,1,LC,\
  161.     Row2,1,LR,\
  162.     Col2,1,RC,\
  163.     Color,1,Nil,\
  164.     UnUsed,1,Nil,\
  165.     TxtPtr,2,Nil,\
  166.     InxPtr,2,0,\
  167.     MasterObj,2,Nil,\
  168.     DispTbl,2,Nil,\
  169.     MenuPtr,2,HelpMenu,\
  170.     MenuTbl,2,HelpMenuTbl>,\
  171.     <Refresh,Select,Flash,DeHilite,Click>
  172.  
  173.  
  174.  
  175.     END
  176.